import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ImagesConst } from "../../../resource/ImagesConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { MsgManager } from "../../../manager/MsgManager";
import { GTextInput } from "../../../../../com/mui/controls/GTextInput";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class TakeOutMoneyWindow
    
    export  class TakeOutMoneyWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.init();
            return;
        }

        public updateGoldText(arg1: int): void
        {
            this._goldInput.text = arg1.toString();
            return;
        }

        public updateCoinText(arg1: int): void
        {
            this._coinInput.text = arg1.toString();
            return;
        }

        public get gold(): int
        {
            this._gold = int(this._goldInput.text);
            return this._gold;
        }

        public get coin(): int
        {
            this._coin = int(this._coinInput.text);
            return this._coin;
        }

        public set storageGold(arg1: int)
        {
            if (this._goldNumText) 
            {
                this._goldNumText.text = arg1.toString();
            }
            return;
        }

        public set storageCoin(arg1: int)
        {
            if (this._coinNumText) 
            {
                this._coinNumText.text = arg1.toString();
            }
            return;
        }

        public set maxGold(arg1: int)
        {
            this._maxGold = arg1;
            return;
        }

        public set maxCoin(arg1: int)
        {
            this._maxCoin = arg1;
            return;
        }

        public set callBackFun(arg1: Function)
        {
            this._callBackFun = arg1;
            return;
        }

        /* internal  */init(): void
        {
            titleHeight = 30;
            this.setSize(260, 210);
            this.title = Language.getString(52015);
            var loc1=ObjCreate.createBg(20, 43, 220, 153, this);
            this._goldInput = ObjCreate.createGTextInput(70, 54, 80, 20, this);
            this._goldInput.restrict = "0-9";
            this._goldInput.maxChars = 8;
            this._goldInput.text = "0";
            this._goldInput.addEventListener(flash.events.Event.CHANGE, this.onMoneyChangeHandler);
            this._goldBitmap = GlobalClass.getBitmap("Yuanbao");
            this._goldBitmap.x = 48;
            this._goldBitmap.y = 54;
            this.addChild(this._goldBitmap);
            this._coinInput = ObjCreate.createGTextInput(70, 80, 80, 20, this);
            this._coinInput.restrict = "0-9";
            this._coinInput.maxChars = 8;
            this._coinInput.text = "0";
            this._coinInput.addEventListener(flash.events.Event.CHANGE, this.onCoinChangeHandler);
            this._coinBitmap = GlobalClass.getBitmap("Tongqian");
            this._coinBitmap.x = 48;
            this._coinBitmap.y = 80;
            this.addChild(this._coinBitmap);
            this._goldOkBtn = ObjCreate.createGButton(Language.getString(52012), 175, 53, 46, 20, this);
            this._goldOkBtn.name = "goldOkBtn";
            this._goldOkBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOkBtnClickHandler);
            this._coinOkBtn = ObjCreate.createGButton(Language.getString(52012), 175, 80, 46, 20, this);
            this._coinOkBtn.name = "coinOkBtn";
            this._coinOkBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOkBtnClickHandler);
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 16776960);
            loc2.leading = 5;
            ObjCreate.createBg(23, 109, 220, 1, this, ImagesConst.SplitLine);
            ObjCreate.createTextField(Language.getString(57656), 24, 114, 220, 50, this, loc2, true);
            ObjCreate.createBg(23, 150, 220, 1, this, ImagesConst.SplitLine);
            this._numText = new Object /* flash.text.TextField */();
            this._numText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._numText.x = 24;
            this._numText.y = 151;
            this._numText.width = 200;
            this._numText.height = 18;
            this._numText.mouseEnabled = false;
            this._numText.filters = [FilterConst.glowFilter];
            this._numText.htmlText = HTMLUtil.addColor(Language.getStringByParam(57629, HTMLUtil.addColor(Language.getString(57630), "#ffff00")), "#CBE1E6");
            this.addChild(this._numText);
            this._bottomGoldBitmap = GlobalClass.getBitmap("Yuanbao");
            this._bottomGoldBitmap.x = 60;
            this._bottomGoldBitmap.y = 177;
            this.addChild(this._bottomGoldBitmap);
            this._bottomCoinBitmap = GlobalClass.getBitmap("Tongqian");
            this._bottomCoinBitmap.x = 145;
            this._bottomCoinBitmap.y = 177;
            this.addChild(this._bottomCoinBitmap);
            this._goldNumText = ObjCreate.createTextField("", 84, 178, 50, 30, this);
            this._coinNumText = ObjCreate.createTextField("", 165, 178, 50, 30, this);
            return;
        }

        /* internal  */onOkBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._callBackFun != null) 
            {
                if (arg1.target.name != "goldOkBtn") 
                {
                    if (arg1.target.name == "coinOkBtn") 
                    {
                        if (this.coin <= 0) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(57641));
                            return;
                        }
                        this._callBackFun(true, 0, this.coin);
                    }
                }
                else 
                {
                    if (this.gold <= 0) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(57640));
                        return;
                    }
                    this._callBackFun(true, this.gold, 0);
                }
            }
            return;
        }

        /* internal  */onMoneyChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this.gold < 10) 
            {
                MsgManager.showRollTipsMsg(Language.getString(57654));
                this.updateGoldText(10);
            }
            else if (this.gold >= 10 && this.gold <= this._maxGold) 
            {
                this.updateGoldText(this.gold);
            }
            else if (this.gold > this._maxGold && this._maxGold < 10) 
            {
                this.updateGoldText(10);
            }
            else if (this.gold > this._maxGold && this._maxGold >= 10) 
            {
                this.updateGoldText(this._maxGold);
            }
            return;
        }

        /* internal  */onCoinChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this.coin < 5000) 
            {
                MsgManager.showRollTipsMsg(Language.getString(57655));
                this.updateCoinText(5000);
            }
            else if (this.coin >= 5000 && this.coin <= this._maxCoin) 
            {
                this.updateCoinText(this.coin);
            }
            else if (this.coin > this._maxCoin && this._maxCoin < 5000) 
            {
                this.updateCoinText(5000);
            }
            else if (this.coin > this._maxCoin && this._maxCoin >= 5000) 
            {
                this.updateCoinText(this._maxCoin);
            }
            return;
        }

        /* internal */ /* var */_goldInput: GTextInput;

        /* internal */ /* var */_coinInput: GTextInput;

        /* internal */ /* var */_goldBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_coinBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_goldOkBtn: GButton;

        /* internal */ /* var */_coinOkBtn: GButton;

        /* internal */ /* var */_numText: Object /* flash.text.TextField */;

        /* internal */ /* var */_goldNumText: Object /* flash.text.TextField */;

        /* internal */ /* var */_coinNumText: Object /* flash.text.TextField */;

        /* internal */ /* var */_bottomGoldBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bottomCoinBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_coin: int;

        /* internal */ /* var */_gold: int;

        /* internal */ /* var */_maxGold: int;

        /* internal */ /* var */_maxCoin: int;

        /* internal */ /* var */_callBackFun: Function=null;
    }
